package org.springblade.modules.admin.controller.suger;

import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.dto.sugar.SugarSearchDTO;
import org.springblade.modules.admin.service.ElevatorByCollectService;
import org.springblade.modules.admin.vo.CheckStatisticsTrendVO;
import org.springblade.modules.admin.vo.MaintainPlanConfigVO;
import org.springblade.modules.admin.vo.sugar.ElevatorByCollectScheduleListVO;
import org.springblade.modules.admin.vo.sugar.ElevatorByCollectVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Date 16:31 2025/8/28
 * @Description {
 *    电梯排期及保养工单数据汇总
 * }
 * @Author lsay
 **/
@AllArgsConstructor
@RequestMapping("/elevator/by/collect")
@RestController
public class ElevatorByCollectController {

	private final ElevatorByCollectService elevatorByCollectService;

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-未完成保养总数，已超15天，今天第15天
	 * }
	 * @Date 17:12 2025/8/28
	 * @Param
	 * @return
	 **/
	@PostMapping("/overdue/count")
	public R<ElevatorByCollectVO> selectOverdueCount(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectOverdueCount(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-超15天逾期率，逾期数，逾期率趋势
	 * }
	 * @Date 11:18 2025/8/29
	 * @Param
	 * @return
	 **/
	@PostMapping("/overdue/rate/trend")
	public R<ElevatorByCollectVO> selectOverdueRateTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectOverdueRateTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-按计划日期完成率，及时率趋势
	 * }
	 * @Date 11:18 2025/8/29
	 * @Param
	 * @return
	 **/
	@PostMapping("/timeliness/rate/trend")
	public R<ElevatorByCollectVO> selectTimelinessRateTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectTimelinessRateTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-工单平均作业时长，平均作业时长趋势
	 * }
	 * @Date 11:18 2025/8/29
	 * @Param
	 * @return
	 **/
	@PostMapping("/work/time/ave/trend")
	public R<ElevatorByCollectVO> selectWorkTimeAveTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectWorkTimeAveTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-保养整改出现率，需整改保养单数，保养整改出现率趋势
	 * }
	 * @Date 15:51 2025/8/29
	 * @Param
	 * @return
	 **/
	@PostMapping("/correlation/zg/trend")
	public R<ElevatorByCollectVO> selectByCorrelationZgTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectByCorrelationZgTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   仪表盘统计卡片-保养整改完成率，按时整改率，保养整改完成率趋势
	 * }
	 * @Date 10:09 2025/9/1
	 * @Param
	 * @return
	 **/
	@PostMapping("/correlation/zg/status/trend")
	public R<ElevatorByCollectVO> selectByCorrelationZgStatusTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectByCorrelationZgStatusTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   电梯保养排期异常监测（实时数据）
	 * }
	 * @Date 16:31 2025/9/2
	 * @Param
	 * @return
	 **/
	@PostMapping("/schedule/label/count/list")
	public R<List<Map<String,Object>>> selectScheduleLabelCountList(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectScheduleLabelCountList(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   电梯保养排期异常监测（实时数据）- 子级数据
	 * }
	 * @Date 10:31 2025/9/3
	 * @Param
	 * @return
	 **/
	@PostMapping("/schedule/label/count/child/list")
	public R<List<ElevatorByCollectScheduleListVO>> selectScheduleLabelCountChildList(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectScheduleLabelCountChildList(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   保养完成情况
	 * }
	 * @Date 9:11 2025/9/4
	 * @Param
	 * @return
	 **/
	@PostMapping("/plan/status/overdue/trend")
	public R<List<CheckStatisticsTrendVO>> selectPlanStatusOverdueTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectPlanStatusOverdueTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *    保养整改出现趋势
	 * }
	 * @Date 10:52 2025/9/4
	 * @Param
	 * @return
	 **/
	@PostMapping("/plan/zg/appear/trend")
	public R<List<CheckStatisticsTrendVO>> selectPlanZgAppearTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectPlanZgAppearTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *    整改处理效率趋势
	 * }
	 * @Date 10:52 2025/9/4
	 * @Param
	 * @return
	 **/
	@PostMapping("/plan/zg/status/trend")
	public R<List<CheckStatisticsTrendVO>> selectPlanZgStatusTrend(@RequestBody SugarSearchDTO searchDTO){
		return R.data(elevatorByCollectService.selectPlanZgStatusTrend(searchDTO));
	}

}
